#include "timer_proc.h"

static uint8_t timer1_5000ms_flag = 0;
static uint8_t timer1_1000ms_flag = 0;
static uint8_t timer1_500ms_flag = 0;
static uint8_t timer1_200ms_flag = 0;
static uint8_t timer1_100ms_flag = 0;
static uint8_t timer1_50ms_flag = 0;
static uint8_t timer1_20ms_flag = 0;
static uint8_t timer1_10ms_flag = 0;
static uint8_t timer1_5ms_flag = 0;
static uint8_t timer1_1ms_flag = 0;



uint8_t check_timer1_5000ms_flag(void)
{
	return timer1_5000ms_flag;
}

void set_timer1_5000ms_flag(uint8_t flag)
{
	timer1_5000ms_flag = flag;
}


uint8_t check_timer1_1000ms_flag(void)
{
	return timer1_1000ms_flag;
}

void set_timer1_1000ms_flag(uint8_t flag)
{
	timer1_1000ms_flag = flag;
}



uint8_t check_timer1_500ms_flag(void)
{
	return timer1_500ms_flag;
}

void set_timer1_500ms_flag(uint8_t flag)
{
	timer1_500ms_flag = flag;
}




uint8_t check_timer1_200ms_flag(void)
{
	return timer1_200ms_flag;
}

void set_timer1_200ms_flag(uint8_t flag)
{
	timer1_200ms_flag = flag;
}


uint8_t check_timer1_100ms_flag(void)
{
	return timer1_100ms_flag;
}

void set_timer1_100ms_flag(uint8_t flag)
{
	timer1_100ms_flag = flag;
}


uint8_t check_timer1_50ms_flag(void)
{
	return timer1_50ms_flag;
}

void set_timer1_50ms_flag(uint8_t flag)
{
	timer1_50ms_flag = flag;
}


uint8_t check_timer1_20ms_flag(void)
{
	return timer1_20ms_flag;
}

void set_timer1_20ms_flag(uint8_t flag)
{
	timer1_20ms_flag = flag;
}

uint8_t check_timer1_10ms_flag(void)
{
	return timer1_10ms_flag;
}

void set_timer1_10ms_flag(uint8_t flag)
{
	timer1_10ms_flag = flag;
}

uint8_t check_timer1_5ms_flag(void)
{
	return timer1_5ms_flag;
}

void set_timer1_5ms_flag(uint8_t flag)
{
	timer1_5ms_flag = flag;
}


uint8_t check_timer1_1ms_flag(void)
{
	return timer1_1ms_flag;
}

void set_timer1_1ms_flag(uint8_t flag)
{
	timer1_1ms_flag = flag;
}


void timer1_update_irq_callback(void)
{
	static uint16_t timer1_5000ms_cnt = 0;
	static uint16_t timer1_1000ms_cnt = 9;
	static uint16_t timer1_500ms_cnt = 8;
	static uint16_t timer1_200ms_cnt = 7;
	static uint16_t timer1_100ms_cnt = 6;
	static uint16_t timer1_50ms_cnt = 5;
	static uint16_t timer1_20ms_cnt = 4;
	static uint16_t timer1_10ms_cnt = 3;
	static uint16_t timer1_5ms_cnt = 2;
	static uint16_t timer1_1ms_cnt = 1;	

	//5000ms
	if(++timer1_5000ms_cnt >= 5000)
	{
		timer1_5000ms_cnt = 0;
		set_timer1_5000ms_flag(1);
	}	
	//1000ms
	if(++timer1_1000ms_cnt >= 1000)
	{
		timer1_1000ms_cnt = 0;
		set_timer1_1000ms_flag(1);
	}	
	
	//500ms
	if(++timer1_500ms_cnt >= 500)
	{
		timer1_500ms_cnt = 0;
		set_timer1_500ms_flag(1);
	}
	
	//200ms
	if(++timer1_200ms_cnt >= 200)
	{
			timer1_200ms_cnt = 0;
			set_timer1_200ms_flag(1);
	}
	//100ms
	if(++timer1_100ms_cnt >= 100)
	{
		timer1_100ms_cnt = 0;
		set_timer1_100ms_flag(1);
	}	
	//50ms
	if(++timer1_50ms_cnt >= 50)
	{
		timer1_50ms_cnt = 0;
		set_timer1_50ms_flag(1);	
	}	
	//20ms
	if(++timer1_20ms_cnt >= 20)
	{
		timer1_20ms_cnt = 0;
		set_timer1_20ms_flag(1);
	}
	
	//10ms
	if(++timer1_10ms_cnt >= 10)
	{
		timer1_10ms_cnt = 0;
		set_timer1_10ms_flag(1);	
	}
	//5ms
	if(++timer1_5ms_cnt >= 5)
	{
		timer1_5ms_cnt = 0;
		set_timer1_5ms_flag(1);	
	}
	//1ms
	if(++timer1_1ms_cnt >= 1)
	{
		timer1_1ms_cnt = 0;
		set_timer1_1ms_flag(1);	
	}	
	
}

